<!DOCTYPE html>
<html lang="en">
<head>

	<meta charset="utf-8">
	<title>Edit Resident</title>
	<link rel="stylesheet" href="<?php echo base_url();?>/application/development-bundle/themes/custom-theme/jquery.ui.all.css">
	<link rel="stylesheet" href="<?php echo base_url();?>/application/css/style.css">
	<script src="<?php echo base_url();?>/application/development-bundle/jquery-1.4.4.js"></script>
	<script src="<?php echo base_url();?>/application/development-bundle/ui/jquery.ui.core.js"></script>
	<script src="<?php echo base_url();?>/application/development-bundle/ui/jquery.ui.widget.js"></script>
	<script src="<?php echo base_url();?>/application/development-bundle/ui/jquery.ui.accordion.js"></script>
	<script src="<?php echo base_url();?>/application/development-bundle/ui/jquery.ui.datepicker.js"></script>
	<link rel="stylesheet" href="<?php echo base_url();?>/application/development-bundle/demos/demos.css">
	
	<style>
		#accordion {width: 310px;}
	</style>
	
	<script>
	$(function() {
		$( "#accordion" ).accordion({
			autoHeight: false,
			navigation: true,
			collapsible: true,
			active: -1
		});
	});
	</script>
	
	<script>
	$(function() {
		$( "#datepicker" ).datepicker({
			changeMonth: true,
			changeYear: true,
			dateFormat: 'yy/mm/dd',
			yearRange: '1950:2099'
		});
	});
	</script>
	
	<script>
	function OnSubmitForm(){
		if(document.pressed == "Edit Resident"){
			if(document.adminform.student_number.value!=""){
				document.adminform.action ="<?php echo base_url();?>/index.php/residentController/editResident";
				return true;
			}else{
				alert("Please enter student number!");
				return false;
			}
		
		}else if(document.pressed == "Main Menu"){
			document.adminform.action ="<?php echo base_url();?>/index.php/adminPageController";
			return true;
		}
	}
	</script>
	
</head>

<body>

<div class="demo">
	
	<div id="header"><h1>ACCI eXtreme Information System</h1></div>

	<div id="accordion">
	
		<h3><a href="#section1">Edit a Resident</a></h3>
		<form name="adminform" method="post" onSubmit="return OnSubmitForm();">
			<h3>Resident's Information</h3>
			<div>
				<?php if($data->num_rows()>0){?>
				<?php foreach($data->result() as $row):?>
				<table>
					<tr>
						<td align="center" colspan="2">
							Student Number:<br/><input disabled="true" type="text" value="<?php echo $row->student_number;?>"/>
							<input type="hidden" name="student_number" value="<?php echo $row->student_number;?>"/>
						</td>
					</tr>
					<tr>
						<td align="center"><br/><br/>
							First Name:<br/><input type="text" name="first_name" value="<?php echo $row->first_name;?>"/>
							Middle Name:<br/><input type="text" name="middle_name" value="<?php echo $row->middle_name;?>"/>
							Last Name:<br/><input type="text" name="last_name" value="<?php echo $row->last_name;?>"/>
							Gender:<br/><input type="text" name="gender" value="<?php echo $row->gender;?>"/>
							Civil Status:<br/><input type="text" name="civil_status" value="<?php echo $row->civil_status;?>"/>
							Birthday:<br/><input type="text" name="birthday" id="datepicker" value="<?php echo $row->birthday;?>"/>
							Religion:<br/><input type="text" name="religion" value="<?php echo $row->religion;?>"/>
						</td>
						<td align="center"><br/><br/>
							Course:<br/><input type="text" name="course" value="<?php echo $row->course;?>"/>
							College:<br/><input type="text" name="college" value="<?php echo $row->college;?>"/>
							Classification:<br/>
								<select name="classification">
								<option <?php if($row->classification=="Freshman") echo "selected=\"true\"";?>>Freshman</option>
								<option <?php if($row->classification=="Sophomore") echo "selected=\"true\"";?>>Sophomore</option>
								<option <?php if($row->classification=="Junior") echo "selected=\"true\"";?>>Junior</option>
								<option <?php if($row->classification=="Senior") echo "selected=\"true\"";?>>Senior</option>
								</select>
							Home Address:<br/><input type="text" name="home_address" value="<?php echo $row->home_address;?>"/>
							Telephone Number:<br/><input type="text" name="telephone_number" value="<?php echo $row->telephone_number;?>"/>
							Email Address:<br/><input type="text" name="email_address" value="<?php echo $row->email_address;?>"/>
							Region:<br/><input type="text" name="region" value="<?php echo $row->region;?>"/>
						</td>
					</tr>
					<tr>
						<td colspan="2" align="center"><br/><br/>
							Name of Father:<br/><input type="text" name="name_of_father" size="40" value="<?php echo $row->name_of_father;?>"/><br/>
							Contact Number:<br/><input type="text" name="telnumber_of_father" size="40" value="<?php echo $row->telnumber_of_father;?>"/><br/>
							Name of Mother:<br/><input type="text" name="name_of_mother" size="40" value="<?php echo $row->name_of_mother;?>"/><br/>
							Contact Number:<br/><input type="text" name="telnumber_of_mother" size="40" value="<?php echo $row->telnumber_of_mother;?>"/><br/>
							Guardian:<br/><input type="text" name="name_of_guardian" size="40" value="<?php echo $row->name_of_guardian;?>"/><br/>
							Contact Number:<br/><input type="text" name="telnumber_of_guardian" size="40" value="<?php echo $row->telnumber_of_guardian;?>"/><br/>
						</td>
					</tr>
				</table><br/>
				<input type="reset"/>
				<input type="submit" value="Edit Resident" onClick="document.pressed=this.value" />
				<?php endforeach;?>
				<?php }else{?>
					Student not found<br/><br/>
				<?php }?>
				<input type="submit" value="Main Menu" onClick="document.pressed=this.value" />
			</div>
		</form>
		
	</div><!-- End accordion -->

</div><!-- End demo -->

</body>
</html>
